#pragma once

#include <gofcl_dma_r.h>

typedef enum {
	DMA_CH0_R = 0x8,
	DMA_CH1_R = 0x1C,
	DMA_CH2_R = 0x30,
	DMA_CH3_R = 0x44,
	DMA_CH4_R = 0x58,
	DMA_CH5_R = 0x6C,
	DMA_CH6_R = 0x80,
} dma_ch_re;

typedef enum {
	DMA_CH_CTL_RR = 0x0,
	DMA_CH_CNT_RR = 0x4,
	DMA_CH_PADDR_RR = 0x8,
	DMA_CH_MADDR_RR = 0xC,
} dma_ch_rre;

static inline u32_s dma_get_ch_reg_q(dma_qe dma_q, dma_ch_re dma_ch_r,
				     dma_ch_rre dma_ch_rr) {
	return dma_q + dma_ch_r + dma_ch_rr;
}

static inline void dma_wreg_ch(dma_qe dma_q, dma_ch_re dma_ch_r,
			       dma_ch_rre dma_ch_rr, u32_s value) {
	u32_s reg_q = dma_get_ch_reg_q(dma_q, dma_ch_r, dma_ch_rr);
	wreg(reg_q, value);
}

static inline u32_s dma_rreg_ch(dma_qe dma_q, dma_ch_re dma_ch_r,
				dma_ch_rre dma_ch_rr) {
	u32_s reg_q = dma_get_ch_reg_q(dma_q, dma_ch_r, dma_ch_rr);
	return rreg(reg_q);
}
